unit uniCadPrevisaoEntregaOld;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls, Mask, Grids, DBGrids, ExtCtrls, DB, ADODB;

type
  TfrmCadPrevisaoEntregaOld = class(TForm)
    Panel4: TPanel;
    Panel3: TPanel;
    Label5: TLabel;
    lblCodigoPedido: TLabel;
    Label9: TLabel;
    Label11: TLabel;
    medtEntrega: TMaskEdit;
    Panel1: TPanel;
    edtQuantidade: TEdit;
    Label1: TLabel;
    edtCdFatura: TEdit;
    btnIncluir: TSpeedButton;
    btnEditar: TSpeedButton;
    btnExcluir: TSpeedButton;
    btnGravar: TSpeedButton;
    btnCancelar: TSpeedButton;
    btnFechar: TSpeedButton;
    QR_Padrao: TADOQuery;
    DS_Padrao: TDataSource;
    Grid: TDBGrid;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    gCdPedido:String;
  end;

var
  frmCadPrevisaoEntregaOld: TfrmCadPrevisaoEntregaOld;

implementation

{$R *.dfm}

procedure TfrmCadPrevisaoEntregaOld.FormShow(Sender: TObject);
begin
  //Abrir tabela principal
  QR_Padrao.Close;
  QR_Padrao.SQL.Text := ' SELECT PE.*, F.DS_FATURA '+
                        ' FROM TB_PREVISAO_ENTREGA PE LEFT OUTER JOIN TB_FATURA F '+
                        ' ON  PE.CD_FATURA = F.CD_FATURA '+
                        ' WHERE PE.CD_PEDIDO = '+QuotedStr(gCdPedido);
  QR_Padrao.Open;

end;

end.
